You can interact with this notebook online: Launch notebook
Analysing Spectrum¶
Every simulation run requires atomic data and a configuration file.
Atomic Data¶
We recommend using the kurucz_cd23_chianti_H_He.h5 dataset.
[1]:
from tardis.io.atom_data import download_atom_data
# We download the atomic data needed to run the simulation
download_atom_data("kurucz_cd23_chianti_H_He")
Atomic Data kurucz_cd23_chianti_H_He already exists in /home/abhinav/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5. Will not download - override with force_download=True.
You can also obtain a copy of the atomic data from the tardis-regression-data repository.
Example Configuration File¶
The configuration file tardis_example.yml is used throughout this Quickstart.
[2]:
!wget -q -nc https://raw.githubusercontent.com/tardis-sn/tardis/master/docs/tardis_example.yml
[3]:
!cat tardis_example.yml
# Example YAML configuration for TARDIS
tardis_config_version: v1.0
supernova:
luminosity_requested: 9.44 log_lsun
time_explosion: 13 day
atom_data: kurucz_cd23_chianti_H_He.h5
model:
structure:
type: specific
velocity:
start: 1.1e4 km/s
stop: 20000 km/s
num: 20
density:
type: branch85_w7
abundances:
type: uniform
O: 0.19
Mg: 0.03
Si: 0.52
S: 0.19
Ar: 0.04
Ca: 0.03
plasma:
disable_electron_scattering: no
ionization: lte
excitation: lte
radiative_rates_type: dilute-blackbody
line_interaction_type: macroatom
montecarlo:
seed: 23111963
no_of_packets: 4.0e+4
iterations: 20
nthreads: 1
last_no_of_packets: 1.e+5
no_of_virtual_packets: 10
convergence_strategy:
type: damped
damping_constant: 1.0
threshold: 0.05
fraction: 0.8
hold_iterations: 3
t_inner:
damping_constant: 0.5
spectrum:
start: 500 angstrom
stop: 20000 angstrom
num: 10000
Running the Simulation¶
To run the simulation, import the run_tardis function and create the sim object.
Note:
Get more information about the progress bars, logging configuration, and convergence plots.
[4]:
from tardis import run_tardis
sim = run_tardis(
"tardis_example.yml",
virtual_packet_logging=True,
show_convergence_plots=True,
export_convergence_plots=True,
log_level="INFO",
)
[tardis.io.model.parse_atom_data][INFO ]
Reading Atomic Data from kurucz_cd23_chianti_H_He.h5 (parse_atom_data.py:40)
[tardis.io.atom_data.util][INFO ]
Atom Data kurucz_cd23_chianti_H_He.h5 not found in local path.
Exists in TARDIS Data repo /home/abhinav/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5 (util.py:34)
[tardis.io.atom_data.base][INFO ]
Reading Atom Data with: UUID = 6f7b09e887a311e7a06b246e96350010 MD5 = 864f1753714343c41f99cb065710cace (base.py:258)
[tardis.io.atom_data.base][INFO ]
Non provided Atomic Data: synpp_refs, photoionization_data, yg_data, two_photon_data, linelist_atoms, linelist_molecules (base.py:262)
[tardis.io.model.parse_density_configuration][WARNING]
Number of density points larger than number of shells. Assuming inner point irrelevant (parse_density_configuration.py:114)
[tardis.model.matter.decay][INFO ]
Decaying abundances for 1123200.0 seconds (decay.py:101)
[tardis.simulation.base][INFO ]
Starting iteration 1 of 20 (base.py:444)
[py.warnings ][WARNING]
/home/abhinav/workspace/code/tardis-main/tardis-code/tardis/tardis/transport/montecarlo/montecarlo_main_loop.py:123: NumbaTypeSafetyWarning:
unsafe cast from uint64 to int64. Precision may be lost.
(warnings.py:112)
[tardis.simulation.base][INFO ]
Luminosity emitted = 7.942e+42 erg / s
Luminosity absorbed = 2.659e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 9.93e+03 K | 1.01e+04 K | 0.4 | 0.507 |
| 5 | 9.85e+03 K | 1.02e+04 K | 0.211 | 0.197 |
| 10 | 9.78e+03 K | 1.01e+04 K | 0.143 | 0.117 |
| 15 | 9.71e+03 K | 9.87e+03 K | 0.105 | 0.0869 |
[tardis.simulation.base][INFO ]
Current t_inner = 9933.952 K
Expected t_inner for next iteration = 10703.212 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 2 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.071e+43 erg / s
Luminosity absorbed = 3.576e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.01e+04 K | 1.08e+04 K | 0.507 | 0.525 |
| 5 | 1.02e+04 K | 1.1e+04 K | 0.197 | 0.203 |
| 10 | 1.01e+04 K | 1.08e+04 K | 0.117 | 0.125 |
| 15 | 9.87e+03 K | 1.05e+04 K | 0.0869 | 0.0933 |
[tardis.simulation.base][INFO ]
Current t_inner = 10703.212 K
Expected t_inner for next iteration = 10673.712 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 3 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.074e+43 erg / s
Luminosity absorbed = 3.391e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 1/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.08e+04 K | 1.1e+04 K | 0.525 | 0.483 |
| 5 | 1.1e+04 K | 1.12e+04 K | 0.203 | 0.189 |
| 10 | 1.08e+04 K | 1.1e+04 K | 0.125 | 0.118 |
| 15 | 1.05e+04 K | 1.06e+04 K | 0.0933 | 0.0895 |
[tardis.simulation.base][INFO ]
Current t_inner = 10673.712 K
Expected t_inner for next iteration = 10635.953 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 4 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.058e+43 erg / s
Luminosity absorbed = 3.352e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 2/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.1e+04 K | 0.483 | 0.469 |
| 5 | 1.12e+04 K | 1.12e+04 K | 0.189 | 0.182 |
| 10 | 1.1e+04 K | 1.1e+04 K | 0.118 | 0.113 |
| 15 | 1.06e+04 K | 1.07e+04 K | 0.0895 | 0.0861 |
[tardis.simulation.base][INFO ]
Current t_inner = 10635.953 K
Expected t_inner for next iteration = 10638.407 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 5 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.055e+43 erg / s
Luminosity absorbed = 3.399e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 3/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.1e+04 K | 0.469 | 0.479 |
| 5 | 1.12e+04 K | 1.13e+04 K | 0.182 | 0.178 |
| 10 | 1.1e+04 K | 1.1e+04 K | 0.113 | 0.113 |
| 15 | 1.07e+04 K | 1.07e+04 K | 0.0861 | 0.0839 |
[tardis.simulation.base][INFO ]
Current t_inner = 10638.407 K
Expected t_inner for next iteration = 10650.202 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 6 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.061e+43 erg / s
Luminosity absorbed = 3.398e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 4/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.1e+04 K | 0.479 | 0.47 |
| 5 | 1.13e+04 K | 1.12e+04 K | 0.178 | 0.185 |
| 10 | 1.1e+04 K | 1.11e+04 K | 0.113 | 0.112 |
| 15 | 1.07e+04 K | 1.07e+04 K | 0.0839 | 0.0856 |
[tardis.simulation.base][INFO ]
Current t_inner = 10650.202 K
Expected t_inner for next iteration = 10645.955 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 7 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.061e+43 erg / s
Luminosity absorbed = 3.382e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 5/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.1e+04 K | 0.47 | 0.47 |
| 5 | 1.12e+04 K | 1.13e+04 K | 0.185 | 0.178 |
| 10 | 1.11e+04 K | 1.11e+04 K | 0.112 | 0.112 |
| 15 | 1.07e+04 K | 1.07e+04 K | 0.0856 | 0.086 |
[tardis.simulation.base][INFO ]
Current t_inner = 10645.955 K
Expected t_inner for next iteration = 10642.050 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 8 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.062e+43 erg / s
Luminosity absorbed = 3.350e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 6/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.11e+04 K | 0.47 | 0.472 |
| 5 | 1.13e+04 K | 1.14e+04 K | 0.178 | 0.175 |
| 10 | 1.11e+04 K | 1.11e+04 K | 0.112 | 0.111 |
| 15 | 1.07e+04 K | 1.07e+04 K | 0.086 | 0.084 |
[tardis.simulation.base][INFO ]
Current t_inner = 10642.050 K
Expected t_inner for next iteration = 10636.106 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 9 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.052e+43 erg / s
Luminosity absorbed = 3.411e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 7/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.11e+04 K | 1.11e+04 K | 0.472 | 0.469 |
| 5 | 1.14e+04 K | 1.15e+04 K | 0.175 | 0.17 |
| 10 | 1.11e+04 K | 1.11e+04 K | 0.111 | 0.109 |
| 15 | 1.07e+04 K | 1.08e+04 K | 0.084 | 0.0822 |
[tardis.simulation.base][INFO ]
Current t_inner = 10636.106 K
Expected t_inner for next iteration = 10654.313 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 10 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.070e+43 erg / s
Luminosity absorbed = 3.335e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 8/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.11e+04 K | 1.1e+04 K | 0.469 | 0.475 |
| 5 | 1.15e+04 K | 1.14e+04 K | 0.17 | 0.177 |
| 10 | 1.11e+04 K | 1.11e+04 K | 0.109 | 0.112 |
| 15 | 1.08e+04 K | 1.06e+04 K | 0.0822 | 0.0878 |
[tardis.simulation.base][INFO ]
Current t_inner = 10654.313 K
Expected t_inner for next iteration = 10628.190 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 11 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.053e+43 erg / s
Luminosity absorbed = 3.363e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 9/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.1e+04 K | 0.475 | 0.472 |
| 5 | 1.14e+04 K | 1.12e+04 K | 0.177 | 0.184 |
| 10 | 1.11e+04 K | 1.1e+04 K | 0.112 | 0.114 |
| 15 | 1.06e+04 K | 1.06e+04 K | 0.0878 | 0.0859 |
[tardis.simulation.base][INFO ]
Current t_inner = 10628.190 K
Expected t_inner for next iteration = 10644.054 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 12 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.056e+43 erg / s
Luminosity absorbed = 3.420e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 10/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.11e+04 K | 0.472 | 0.467 |
| 5 | 1.12e+04 K | 1.13e+04 K | 0.184 | 0.176 |
| 10 | 1.1e+04 K | 1.11e+04 K | 0.114 | 0.11 |
| 15 | 1.06e+04 K | 1.08e+04 K | 0.0859 | 0.0821 |
[tardis.simulation.base][INFO ]
Current t_inner = 10644.054 K
Expected t_inner for next iteration = 10653.543 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 13 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.062e+43 erg / s
Luminosity absorbed = 3.406e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 11/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.11e+04 K | 1.11e+04 K | 0.467 | 0.466 |
| 5 | 1.13e+04 K | 1.13e+04 K | 0.176 | 0.18 |
| 10 | 1.11e+04 K | 1.11e+04 K | 0.11 | 0.111 |
| 15 | 1.08e+04 K | 1.08e+04 K | 0.0821 | 0.0841 |
[tardis.simulation.base][INFO ]
Current t_inner = 10653.543 K
Expected t_inner for next iteration = 10647.277 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 14 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.063e+43 erg / s
Luminosity absorbed = 3.369e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 12/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.11e+04 K | 1.11e+04 K | 0.466 | 0.469 |
| 5 | 1.13e+04 K | 1.13e+04 K | 0.18 | 0.182 |
| 10 | 1.11e+04 K | 1.1e+04 K | 0.111 | 0.113 |
| 15 | 1.08e+04 K | 1.07e+04 K | 0.0841 | 0.0854 |
[tardis.simulation.base][INFO ]
Current t_inner = 10647.277 K
Expected t_inner for next iteration = 10638.875 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 15 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.053e+43 erg / s
Luminosity absorbed = 3.417e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 13/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.11e+04 K | 1.1e+04 K | 0.469 | 0.484 |
| 5 | 1.13e+04 K | 1.13e+04 K | 0.182 | 0.181 |
| 10 | 1.1e+04 K | 1.1e+04 K | 0.113 | 0.113 |
| 15 | 1.07e+04 K | 1.07e+04 K | 0.0854 | 0.0858 |
[tardis.simulation.base][INFO ]
Current t_inner = 10638.875 K
Expected t_inner for next iteration = 10655.125 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 16 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.059e+43 erg / s
Luminosity absorbed = 3.445e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 14/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.1e+04 K | 0.484 | 0.472 |
| 5 | 1.13e+04 K | 1.13e+04 K | 0.181 | 0.177 |
| 10 | 1.1e+04 K | 1.1e+04 K | 0.113 | 0.113 |
| 15 | 1.07e+04 K | 1.06e+04 K | 0.0858 | 0.0858 |
[tardis.simulation.base][INFO ]
Current t_inner = 10655.125 K
Expected t_inner for next iteration = 10655.561 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 17 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.067e+43 erg / s
Luminosity absorbed = 3.372e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 15/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.1e+04 K | 1.11e+04 K | 0.472 | 0.468 |
| 5 | 1.13e+04 K | 1.14e+04 K | 0.177 | 0.175 |
| 10 | 1.1e+04 K | 1.11e+04 K | 0.113 | 0.11 |
| 15 | 1.06e+04 K | 1.08e+04 K | 0.0858 | 0.0816 |
[tardis.simulation.base][INFO ]
Current t_inner = 10655.561 K
Expected t_inner for next iteration = 10636.536 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 18 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.057e+43 erg / s
Luminosity absorbed = 3.365e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 16/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.11e+04 K | 1.11e+04 K | 0.468 | 0.464 |
| 5 | 1.14e+04 K | 1.13e+04 K | 0.175 | 0.177 |
| 10 | 1.11e+04 K | 1.1e+04 K | 0.11 | 0.113 |
| 15 | 1.08e+04 K | 1.07e+04 K | 0.0816 | 0.0848 |
[tardis.simulation.base][INFO ]
Current t_inner = 10636.536 K
Expected t_inner for next iteration = 10641.692 K
(base.py:652)
[tardis.simulation.base][INFO ]
Starting iteration 19 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.056e+43 erg / s
Luminosity absorbed = 3.405e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
[tardis.simulation.base][INFO ]
Iteration converged 17/4 consecutive times. (base.py:260)
[tardis.simulation.base][INFO ]
Plasma stratification: (base.py:625)
| Shell No. | t_rad | next_t_rad | w | next_w |
|---|---|---|---|---|
| 0 | 1.11e+04 K | 1.11e+04 K | 0.464 | 0.466 |
| 5 | 1.13e+04 K | 1.13e+04 K | 0.177 | 0.177 |
| 10 | 1.1e+04 K | 1.11e+04 K | 0.113 | 0.111 |
| 15 | 1.07e+04 K | 1.07e+04 K | 0.0848 | 0.0853 |
[tardis.simulation.base][INFO ]
Current t_inner = 10641.692 K
Expected t_inner for next iteration = 10650.463 K
(base.py:652)
[tardis.simulation.base][INFO ]
Simulation finished in 19 iterations
Simulation took 52.54 s
(base.py:542)
[tardis.simulation.base][INFO ]
Starting iteration 20 of 20 (base.py:444)
[tardis.simulation.base][INFO ]
Luminosity emitted = 1.061e+43 erg / s
Luminosity absorbed = 3.401e+42 erg / s
Luminosity requested = 1.059e+43 erg / s
(base.py:657)
HDF¶
TARDIS can save simulation data to HDF files for later analysis. The code below shows how to load a simulation from an HDF file. This is useful when you want to analyze simulation results without re-running the simulation.
[5]:
# import astropy.units as u
# import pandas as pd
# hdf_fpath = "add_file_path_here"
# with pd.HDFStore(hdf_fpath, "r") as hdf:
# sim = u.Quantity(hdf["/simulation"])
Calculate integrated spectrum¶
Note:
It takes about a minute to calculate. Please be patient while it runs.
[ ]:
spectrum_integrated = sim.spectrum_solver.spectrum_integrated
Plotting the Spectrum¶
Now we will plot the spectrum using matplotlib and plotly. The plots show the luminosity density as a function of wavelength.
Wavelength (Å): The x-axis represents the wavelength in Angstroms.
Luminosity density (erg/s/Å): The y-axis represents the luminosity density in erg per second per Angstrom.
Matplotlib¶
We use Matplotlib to create a static plot of the formal integral spectrum that was calculated in the previous step.
The plot provides a visual representation of the spectrum, allowing us to analyze the distribution of luminosity across different wavelengths. The x-axis is limited to the range of 500 to 9000 Angstroms for better visualization.
[10]:
import matplotlib.pyplot as plt
# Create a new figure with specified dimensions
# Width = 10 inches, Height = 6.5 inches for better visualization
# This creates an empty figure that will be used for plotting the spectra
plt.figure(figsize=(10, 6.5))
# Plot the three different spectra from the simulation
spectrum_integrated.plot(label="Formal integral") # Plot spectrum from formal integral solution
# Set the visualization parameters
plt.xlim(500, 9000) # Set x-axis limits from 500 to 9000 Angstroms
plt.title("TARDIS example model spectrum") # Add title to the plot
plt.xlabel("Wavelength [$A$]") # Label x-axis with units
plt.ylabel("Luminosity density [erg/s/$A$]") # Label y-axis with units
plt.legend() # Add legend to distinguish between different spectra
plt.show() # Display the plot
Plotly¶
Here, we use Plotly to create an interactive plot of the virtual packet spectrum generated by the TARDIS simulation.
The plot is interactive, allowing you to zoom in and out, hover over data points to see their values, and toggle the visibility of different traces in the legend. This provides a more dynamic way to explore the spectral data compared to static plots.
[11]:
# Import plotly for interactive plotting
import plotly.graph_objects as go
# Create a new figure for plotting the spectrum
# This creates an empty figure that will be used for plotting the spectra
fig = go.Figure()
# Plot the wavelength spectrum
fig.add_trace(
go.Scatter(
x=sim.spectrum_solver.spectrum_virtual_packets.wavelength,
y=sim.spectrum_solver.spectrum_virtual_packets.luminosity_density_lambda,
mode="lines",
name="Spectrum"
)
)
# Set the visualization parameters
fig.update_layout(
title="TARDIS example model spectrum", # Add title to the plot
xaxis_title="Wavelength (Å)", # Label x-axis with units
yaxis_title="Luminosity density (erg/s/Å)", # Label y-axis with units
xaxis_range=[500, 9000], # Set x-axis limits from 500 to 9000 Angstroms
showlegend=True, # Show legend to distinguish between different spectra
template="plotly_white" # Use white template for better visualization
)
# Display the plot
fig.show()
[ ]: